package com.jiangyg.mall.core.utils;

import java.util.function.Supplier;

/**
 * 类描述：各级别日志输出
 *
 * @author jiangyg
 * @version 4.0
 * @date 2021-10-14
 */
public class Logger {

    public static void trace(org.slf4j.Logger log, Supplier<String> msg) {
        if (log.isTraceEnabled()) {
            log.trace(msg.get());
        }
    }

    public static void trace(org.slf4j.Logger log, Supplier<String> msg, Throwable t) {
        if (log.isTraceEnabled()) {
            log.trace(msg.get(), t);
        }
    }

    public static void debug(org.slf4j.Logger log, Supplier<String> msg) {
        if (log.isDebugEnabled()) {
            log.debug(msg.get());
        }
    }

    public static void debug(org.slf4j.Logger log, Supplier<String> msg, Throwable t) {
        if (log.isDebugEnabled()) {
            log.debug(msg.get(), t);
        }
    }

    public static void info(org.slf4j.Logger log, Supplier<String> msg) {
        if (log.isInfoEnabled()) {
            log.info(msg.get());
        }
    }

    public static void info(org.slf4j.Logger log, Supplier<String> msg, Throwable t) {
        if (log.isInfoEnabled()) {
            log.info(msg.get(), t);
        }
    }

    public static void warn(org.slf4j.Logger log, Supplier<String> msg) {
        if (log.isWarnEnabled()) {
            log.warn(msg.get());
        }
    }

    public static void warn(org.slf4j.Logger log, Supplier<String> msg, Throwable t) {
        if (log.isWarnEnabled()) {
            log.warn(msg.get(), t);
        }
    }

    public static void error(org.slf4j.Logger log, Supplier<String> msg) {
        if (log.isErrorEnabled()) {
            log.error(msg.get());
        }
    }

    public static void error(org.slf4j.Logger log, Supplier<String> msg, Throwable t) {
        if (log.isErrorEnabled()) {
            log.error(msg.get(), t);
        }
    }

}
